<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class npn extends MY_Controller {
    /* 来自父类
     * public $ceeconfigArray;//cee配置
     * public $userinfoArray; //用户信息
     * public $isloginArray; // 用户是否登录
     */
    //析构
    function __construct(){
        parent::__construct();
        //加载数据库
        $this->load->model('Npn_model','_model');
    }
    //精选
	public function index(){
		//商品信息
		$goodsArray = $this->_model->getGoodsArray();//数组，不止有0：商品，还有1：日期
		
		//是否说说推荐的商品
		$goodsid = isset($_GET['id'])?$_GET['id']:'';
		if ($goodsid) {
			if(!empty($goodsid)) {
				$firstgoods = $this->_model->firstgoods($goodsid);
				$goodsArray_true2[] = $firstgoods;
				foreach ($goodsArray[0] as $item){
					$goodsArray_true2[] = $item;
				}
				$goodsArray[0] = $goodsArray_true2;
			}
		}
		
	    //视图中的参数
	    $data = array(
	    		'appid'              => $this->ceeconfigArray['appid'],
	            'pf'                 => $this->session->userdata('pf')?$this->session->userdata('pf'):"qzone",
	            'userinfo'           => $this->userinfoArray,
	            'goodsArray'         => $goodsArray[0],
	            'goodsArrayFromDate' => $goodsArray[1],
	            'controller'         => 'npn',
	    		'goodsid'            => $goodsid
	    );
	    $this->load->view('common/header',$data);
		$this->load->view('npn');//加载视图view
		$this->load->view('common/footer');
	}
	//商品点击
	public function AjaxGoodsClick(){
		/* -----------参数为空--------- */
		if (empty($_GET['id'])) {
			echo json_encode(array('ret'=>-1));//错误
			return false;
		}
		$rs = $this->_model->AjaxGoodsClick($_GET['id']);
		echo $rs;
		return false;
	}
	//
	public function test(){
		//var_dump($this->ceeclass->islogin());
	}
}